package com.aia.ann.web.json;

import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.aia.ann.domain.Demopic;
import com.aia.ann.service.ChiefService;
import com.opensymphony.xwork2.ActionSupport;

public class DemopicJson02 extends ActionSupport {
	/**
	 * Logger for this class
	 */
	private static final Logger logger = Logger.getLogger(DemopicJson02.class);

	private static final long serialVersionUID = 1L;
	private Map root = new HashMap();
	
	private ChiefService chiefService;

	private int start;
	private int limit;
	private String sort;
	private String dir;
	private String SEARCH_EID;
	private String[] idsToDel = new String[200];
	
	public ChiefService getChiefService() {
		return chiefService;
	}

	public void setChiefService(ChiefService chiefService) {
		this.chiefService = chiefService;
	}

	public int getStart() {
		return start;
	}

	public void setStart(int start) {
		this.start = start;
	}

	public int getLimit() {
		return limit;
	}

	public void setLimit(int limit) {
		this.limit = limit;
	}

	public String getSort() {
		return sort;
	}

	public void setSort(String sort) {
		this.sort = sort;
	}

	public String getDir() {
		return dir;
	}

	public void setDir(String dir) {
		this.dir = dir;
	}

	public String getSEARCH_EID() {
		return SEARCH_EID;
	}

	public void setSEARCH_EID(String sEARCHEID) {
		SEARCH_EID = sEARCHEID;
	}

	public void setRoot(Map root) {
		this.root = root;
	}

	public Map getRoot() {
		return root;
	}

	public String list() {
		if (logger.isDebugEnabled()) {
			logger.debug("list() - start"); //$NON-NLS-1$
		}

		chiefService.demopicJsonList02(this);
		if (logger.isDebugEnabled()) {
			logger.debug("list() - end"); //$NON-NLS-1$
		}
		return SUCCESS;
	}
	
	public String del(){
		logger.debug("DemopicJson02 del() start**********************************************");
		int count = 0;
		for(int i = 0; i < getIdsToDel().length; i++){
			if(getIdsToDel()[i] != null){
				int countcicle = chiefService.deleteDemopicByPrimaryKey(getIdsToDel()[i]);
				count += countcicle;
			}
		}
		
		root.put("success", new Boolean(true));
		root.put("count", new Integer(count));
		logger.debug("DemopicJson02 del() end**********************************");
		return SUCCESS;
	}

	public void setIdsToDel(String[] idsToDel) {
		this.idsToDel = idsToDel;
	}

	public String[] getIdsToDel() {
		return idsToDel;
	}
}
